<template>
  <el-submenu
    v-if="menu.list && menu.list.length >= 1"
    :index="menu.menuId + ''"
    :popper-class="'site-sidebar--' + sidebarLayoutSkin + '-popper'">
    <template slot="title" >
      <icon-svg :name="menu.icon || ''" class="site-sidebar__menu-icon"></icon-svg>
      <span>{{ menu.name }}</span>
    </template>
    <sub-menu
      v-for="item in menu.list"
      :key="item.menuId"
      :menu="item"
      :dynamicMenuRoutes="dynamicMenuRoutes">
    </sub-menu>
  </el-submenu>
  <el-menu-item v-else-if="menu.isHide!='1'" :index="menu.menuId + ''" @click="gotoRouteHandle(menu)">
    <icon-svg :name="menu.icon || ''" class="site-sidebar__menu-icon"></icon-svg>
    <span>{{ menu.name }}</span>
  </el-menu-item>
</template>

<script>
import bus from "../busEvent";
  import SubMenu from './sub-menu'
  export default {
    name: 'sub-menu',
    props: {
      menu: {
        type: Object,
        required: true
      },
      dynamicMenuRoutes: {
        type: Array,
        required: true
      }
    },
    components: {
      SubMenu
    },
    computed: {
      sidebarLayoutSkin: {
        get () { return this.$store.state.common.sidebarLayoutSkin }
      }
    },
    methods: {
      // 通过menuId与动态(菜单)路由进行匹配跳转至指定路由
      gotoRouteHandle (menu) {
        var route = this.dynamicMenuRoutes.filter(item => item.meta.menuId === menu.menuId)
        if (route.length >= 1) {
          // console.log(route[0].name,'route[0].name');
          this.$router.push({ name: route[0].name })
        }
      }
    }
  }
</script>
<style lang="less" scoped>
  .el-submenu .el-menu-item {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  li.el-menu-item:hover {
  // color: #333!important;
    background-color: #e1e1e1 !important;
  }

  .el-menu-item.is-active {
    background-color: #fff !important;
  }

  .router-link-active li.el-menu-item {
    background-color: #fff !important;
  }

  ul.el-menu a li.el-menu-item {
    border-bottom: 1px solid #e1e1e1 !important;
  }

  ul.el-menu li.el-submenu ul.el-menu a li.el-menu-item.is-active {
    background-color: #e1e1e1 !important;
    color: #606266 !important;
  }

  ul.el-menu a li.el-menu-item.is-active .el-submenu__title {
    color: #f76767 !important;
  }

  ul.el-menu li.el-submenu ul.el-menu li.el-submenu ul.el-menu a li.el-menu-item.is-active {
    background-color: #e1e1e1 !important;
    color: #606266 !important;
  }

  li.twoSubmenu.is-opened ul li {
    background-color: #fff !important;
  }

  li.is-opened ul.el-menu li.threeSubmenu.is-opened ul li {
    background-color: #fff !important;
  }

  li.is-opened ul.el-menu li.threeSubmenu.is-opened ul li:hover, li.twoSubmenu.is-opened ul li:hover {
    background-color: #e1e1e1 !important;
  }


  //   ul.el-menu li.el-submenu ul.el-menu a li.el-menu-item{
       //       border-bottom: none!important;
       //   }

  ul.el-menu li.el-submenu ul.el-menu li.el-submenu ul.el-menu a li.el-menu-item {
    border-bottom: none !important;
  }

  ul.el-menu li.is-opened ul.el-menu li.is-opened {
    border-bottom: 1px solid #e1e1e1;
  }

  // ,ul.el-menu li.is-active .el-submenu__title
      ul.el-menu li.el-submenu ul.el-menu li.is-active .el-submenu__title {
  span {
    color: #f76767 !important;
  }

  .svg-icon {
    color: #f76767 !important;
  }
  }

  .isCheck {
    color: #f76767 !important;
  }
</style>
